package cn.com.dhcc.app.pub.module.sysmgr.service;

import java.util.Date;

/**
 * 查询参数方法
 * @author SINE
 * @since 1.0
 */
public class SearchProperty {
	/**
	 * 属性名
	 */
	private String propertyName;
	/**
	 * 属性值
	 */
	private Object propertyValue;
	/**
	 * 属性比较类型.
	 */
	private Condition condition;

	/**
	 * 属性比较类型.<br/>
	 * EQ	  相当于SQL 保留字”=”<br/>
	 * LIKE	  相当于SQL 保留字”like ‘%xxx%’ ”<br/>
	 * LT	  相当于SQL 保留字”<”<br/>
	 * GT    相当于SQL 保留字”>”<br/>
	 * LE	   相当于SQL 保留字”<=”<br/>
	 * GE	    相当于SQL 保留字”>=”<br/>
	 * ISNULL	相当于SQL 保留字”is null ”<br/>
	 * ISNOTNULL  相当于SQL 保留字”is not null”<br/>
	 * IN	相当于SQL 保留字”in”<br/>
	 * BETWEEN	相当于SQL 保留字”between … and …” (调用时需要以逗号隔开两个参数，即propertyValue是以逗号隔开的，如：propertyValue=”1,2”,即转化为“between 1 and 2”的形式)
	 */
	public enum Condition {
		EQ, LIKE, LT, GT, LE, GE, ISNULL, ISNOTNULL, IN, BETWEEN;
	}

	/**
	 * 属性数据类型.
	 */
	public enum PropertyType {
		S(String.class), I(Integer.class), L(Long.class), N(Double.class), D(Date.class), B(Boolean.class);

		private Class<?> clazz;

		PropertyType(Class<?> clazz) {
			this.clazz = clazz;
		}

		public Class<?> getValue() {
			return clazz;
		}
	}

	public SearchProperty() {
	}
	public SearchProperty(String propertyName,Object propertyValue, Condition condition ) {
		this.propertyName = propertyName;
		this.propertyValue = propertyValue;
		this.condition = condition;
	}
	public String getPropertyName() {
		return propertyName;
	}

	public void setPropertyName(String propertyName) {
		this.propertyName = propertyName;
	}

	public Object getPropertyValue() {
		return propertyValue;
	}

	public void setPropertyValue(Object propertyValue) {
		this.propertyValue = propertyValue;
	}

	public Condition getCondition() {
		return condition;
	}

	public void setCondition(Condition condition) {
		this.condition = condition;
	}

	@Override
	public String toString() {
		return "SearchProperty [propertyName=" + propertyName + ", propertyValue=" + propertyValue + ", condition="+ condition + "]";
	}

}
